#!/usr/bin/env python
#-*- coding:utf8 -*-
import os
import sys
import urllib
import urllib2
import json
import web
from app.helpers.application_helper import Helper
class Helper(Helper):
    @classmethod
    def node_check(cls,host,token):
        uri = 'http://%s/ocdn/conf/check?token=%s' % (host, token)
        result = Helper.get_node_api(uri)
        if result is None:
            return False
        return result['result']

    @classmethod
    def node_status(cls,host,token):
        uri = 'http://%s/ocdn/status?token=%s' % (host, token)
        result = Helper.get_node_api(uri)
        if result is None:
            return False
        if result['result'] is False:
            return False
        result = result['data']
        data = {
            'system': result['system'],
            'version': result['version'],
            'kernel': result['kernel'],
            'cpu_status':result['cpu']['status'],
            'cup_info':result['cpu']['info'],
            'memory_mem': result['memory']['mem'],
            'network':result['network']
        }
        return data
